/**
 * Create by CaoWenjian
 *
 * @copyRight: 2018
 **/
package com.bjboot.caocao.system.listener;

import com.bjboot.caocao.common.service.JobService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 *@Description ${description}
 *@Author 操文健
 *@Date 2018-09-20 下午3:25
 *@Version 1.0
 **/
@Component
// 确定加载顺序
@Order(value = 1)
public class JobInitListener implements CommandLineRunner {

    private final Logger logger = LoggerFactory.getLogger(JobInitListener.class);
    @Autowired
    private JobService jobService;

    @Override
    public void run(String... args) throws Exception {
        try {
            logger.info("开始初始化系统Job....");
            jobService.initSchedule();
            logger.info("Job引擎初始化完成");
        } catch (Exception e) {
            logger.error("Job引擎初始化出现异常", e);
        }

    }
}
